<template>
	<div class="dialog-container">
		<el-dialog :title="state.dialog.title" v-model="state.dialog.isShowDialog" :close-on-click-modal="false" width="500px">
			<el-form ref="formRef" :model="state.ruleForm" label-width="auto" disabled>
				<el-form-item label="总收入金额" prop="all">
					<el-input v-model="state.ruleForm.all" />
				</el-form-item>
				<el-form-item label="待结算金额" prop="for_settled">
					<el-input v-model="state.ruleForm.for_settled" />
				</el-form-item>
				<el-form-item label="已结算金额" prop="settled">
					<el-input v-model="state.ruleForm.settled" />
				</el-form-item>
				<el-form-item label="可提现金额" prop="balance">
					<el-input v-model="state.ruleForm.balance" />
				</el-form-item>
				<el-form-item label="已提现金额" prop="withdraw">
					<el-input v-model="state.ruleForm.withdraw" />
				</el-form-item>
			</el-form>
		</el-dialog>
	</div>
</template>

<script lang="ts" setup>
import { reactive } from 'vue';
import { usersApi } from '/@/api';

const UsersApi = usersApi();
const state = reactive({
	dialog: {
		isShowDialog: false,
		type: '',
		title: '',
		submitLoading: false,
	},
	ruleForm: {
		all: '',
		for_settled: '',
		settled: '',
		balance: '',
		withdraw: '',
	},
});

/********** 触发事件 **********/
/********** 方法事件 **********/
// 打开
const openDialog = (row: any) => {
	state.dialog.isShowDialog = true;
	state.dialog.title = `「${row.nickname}」收入明细`;
	_usersInfo({ user_id: row.id });
};

/********** 网络请求 **********/
// 用户信息
const _usersInfo = (params: Object) => {
	UsersApi.usersInfo(params).then((res) => {
		state.ruleForm = res.data.info.income
	});
};

/********** 方法向父组件暴露 **********/
defineExpose({ openDialog });
</script>
